/*
 * @Author: 0x9DEFA478
 * @Date: 2021-08-27 13:39:06
 * @LastEditTime: 2021-09-29 15:39:07
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "GUI_User_Page.h"
#include "Peripheral.h"






static void BackCallback(void* page){
  H_UI_Page* Page;

  Page=page;

  H_UI_ExitSelect(Page->Parent);
  
}

static void EnterCallback(void* page){
  H_UI_Page* Page;

  Page=page;
  
}

static void AddCallback(void* page){
  H_UI_Page* Page;
  int Volume;

  Page=page;

  

}

static void SubCallback(void* page){
  H_UI_Page* Page;
  int Volume;

  Page=page;

  
  
}

static void EnterPageCallback(void* page){
  static int used=0;
  
  if(used==0){
    used=-1;
    H_UI_EnterSelect(((H_UI_Page*)page)->Parent);
  }
}

// static void ExitPageCallback(void* page){
// }


static void DisplayPageCallback(void* page){
  H_UI_Page* Page;

  H_Graphics_Area_Param Param;
  int IsUpdate;

  unsigned char strBuffer[32];
  char* str;
  int strWidth;
  int strHeight;

  int Volume;


  Page=page;



  
  GUI_User_ClearBitmapArea(GUI_User_GetDrawStringBitmap(),0,16,128,48);
  Param.S=Bitmap_0x9DEFA478_Logo;
  Param.D=GUI_User_GetDrawStringBitmap();
  Param.sX=0;
  Param.sY=0;
  Param.dX=(Param.D->Width-Param.S->Width)/2;
  Param.dY=20;
  Param.Width=Param.S->Width;
  Param.Height=Param.S->Height;
  H_Graphics_L1Vertical_CopyTo_L1Vertical(&Param);
  

  GUI_User_ClearBitmapArea(GUI_User_GetDrawStringBitmap(),0,0,128,16);

  if(((H_UI*)Page->Parent)->IsSelect==0){
    //无选中
    
    str="主页面";
    H_Font_GetStringSize(Font_LLib_Song,str,&strWidth,&strHeight);
    GUI_User_DrawString(str,Font_LLib_Song,0,(128-strWidth)/2,0,127,63);
  }else{
    //选中

    //显示CPU占用率
    str=H_String(strBuffer,"{f.1}%",(float)H_TS_GetCPULoad()/10.0f);
    H_Font_GetStringSize(Font_ASCII_H,str,&strWidth,&strHeight);
    GUI_User_DrawString(str,Font_ASCII_H,0,0,0,127,63);
    

    //显示刷新帧频率
    str=H_String(strBuffer,"F:{i}",Button_Screen_FPS);
    H_Font_GetStringSize(Font_ASCII_H,str,&strWidth,&strHeight);
    GUI_User_DrawString(str,Font_ASCII_H,0,128-strWidth,0,127,63);


  }  

}

H_StringItem* GUI_User_Page_Main_Init(H_UI* h_ui,H_UI_Callbacks* Callbacks){


  

  GUI_User_Page_GetDefaultCallbacks(Callbacks);
  Callbacks->DisplayPageCallback=DisplayPageCallback;
  Callbacks->BackCallback=BackCallback;
  Callbacks->EnterCallback=EnterCallback;
  Callbacks->AddCallback=AddCallback;
  Callbacks->SubCallback=SubCallback;
  Callbacks->EnterPageCallback=EnterPageCallback;
  

  return NULL;
}

void GUI_User_Page_Main_DeInit(H_StringItem* stringitem){
}
